package com.prolificinteractive.materialcalendarview.spans;


import ohos.agp.components.Text;
import ohos.agp.render.Canvas;
import ohos.agp.render.Paint;
import ohos.agp.utils.Color;

/**
 * Span to draw a dot centered under a section of text
 */
public class DotSpan {

    /**
     * Default radius used
     */
    public static final float DEFAULT_RADIUS = 10;

    private final float radius;
    private final int color;

    /**
     * Create a span to draw a dot using default radius and color
     *
     * @see #DotSpan(float, int)
     * @see #DEFAULT_RADIUS
     */
    public DotSpan() {
        this.radius = DEFAULT_RADIUS;
        this.color = 0;
    }

    /**
     * Create a span to draw a dot using a specified color
     *
     * @param color color of the dot
     * @see #DotSpan(float, int)
     * @see #DEFAULT_RADIUS
     */
    public DotSpan(int color) {
        this.radius = DEFAULT_RADIUS;
        this.color = color;
    }

    /**
     * Create a span to draw a dot using a specified radius
     *
     * @param radius radius for the dot
     * @see #DotSpan(float, int)
     */
    public DotSpan(float radius) {
        this.radius = radius;
        this.color = 0;
    }

    /**
     * Create a span to draw a dot using a specified radius and color
     *
     * @param radius radius for the dot
     * @param color color of the dot
     */
    public DotSpan(float radius, int color) {
        this.radius = radius;
        this.color = color;
    }

    public void drawBackground(Canvas canvas, Paint paint, Text text) {
        if (color != 0) {
            paint.setColor(new Color(color));
        }
        paint.setStyle(Paint.Style.FILL_STYLE);
        canvas.drawCircle(text.getWidth() / 2f, text.getHeight() - 9 * radius, radius, paint);
    }
}
